package com.example.syssoft.domain;


import com.example.syssoft.common.entities.LogicEntity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Where;

import javax.persistence.*;

@Entity
@Getter
@Setter
@Inheritance
@Where(clause = "is_deleted = 0")
@Table(name = "t_line_item")
@JsonIgnoreProperties(value = {"handler","hibernateLazyInitializer","fieldHandler"})
public class LineItem extends LogicEntity {

    @Schema(description = "数量")
    @Column
    private Integer count;

    @Schema(description = "总价（小项）")
    @Column
    private Double totalPrice;

    @ManyToOne(fetch = FetchType.LAZY)
    @JsonIgnoreProperties(value = {"lineItems","order","orders","item"})
    @Schema(description = "商品")
    private Item item;

    @ManyToOne(fetch = FetchType.LAZY)
    @JsonIgnoreProperties(value = {"lineItems","order","orders","item"})
    @Schema(description = "隶属订单")
    private Order order;
}
